package com.study.util;

import com.study.bean.Result;
import lombok.experimental.UtilityClass;

/**
 * @Author chenyeqing
 * @Date 2021/11/29 22:14
 */
@UtilityClass
public class ResultUtil {

    /**
     * 成功并且有返回值
     * @param data
     * @return
     */
    public Result success(Object data) {
        return new Result(200, "成功", data);
    }

    /**
     * 成功并且有返回值
     * @param data
     * @return
     */
    public Result success(String msg, Object data) {
        return new Result(200, msg, data);
    }

    /**
     * 成功无返回值
     * @return
     */
    public Result success() {
        return success(null);
    }

    /**
     * 成功有提示
     * @return
     */
    public Result success(String msg) {
        return new Result(200, msg, null);
    }

    /**
     * 错误无返回值
     * @param code
     * @param msg
     * @return
     */
    public Result error(Integer code, String msg) {
        return new Result(code, msg, null);
    }

    /**
     * 错误无返回值
     * @param msg
     * @return
     */
    public Result error(String msg) {
        return new Result(500, msg, null);
    }

}
